home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: Getting date in UNIX
- Date: 21 Mar 1996 10:58:36 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4irubc$dkf@umbc9.umbc.edu>
- References: <4ik447$bn7@raffles.technet.sg> <4ike32$c8n@ccshst05.cs.uoguelph.ca>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- Leonard Sim (leonard@pacific.net.sg) wrote:
- >> Can anyone please inform me how to obtain the date in UNIX C??
- >> I just need the date in this format "dd/mm/yyyy". Thanks!!!
-
- Toby K Hay <thay@uoguelph.ca> wrote:
- > I just did this for the first time using an example from my Turbo C
- > reference by Herb Schildt. (Will mentioning that name start another
- > long thread on his failings?)
-
- Actually it will because your #include statements should be enclosed
- in <> instead of "".
-
- > #include "time.h"
- > #include "stdio.h"
- > int main(void)
-
- I find that hard to believe Schildt wrote that declaration. Perhaps you
- took the initiative and fixed it? Good going!
-
- |> { struct tm *ptr;
- |> time_t lt;
- |>
- |> lt = time(NULL);
- |> ptr = localtime(<);
- |> printf(asctime(ptr));
-
- There's just something I don't like about using printf() like that. I mean
- you are trying to print a string, which by the way isn't in the format the
- poster asked for, but don't give printf() a format specification.
-
- I'd recommend looking at the strftime() function and building the string
- from scratch and then printing it.
-
- |> return 0;
- |> }
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-